﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using DAL;
using Entities;
using System.Data;

namespace BLL
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {
        En_Users e_u = new En_Users();
        DAL_Users d_u = new DAL_Users();
        En_Request e_r = new En_Request();
        DAL_Request d_r = new DAL_Request();
        List<En_Facility> Lef = new List<En_Facility>();
        [WebMethod]
        public int getNameLogin(string userName)
        {
            int userType;
            userType = d_u.getNameLogin(userName);
            return userType;
        }

        [WebMethod]
        public int CheckLogin(string userName, string password)
        {
            int result;
            result = d_u.checkLogin(userName, password);
            return result;
        }
        [WebMethod]
        public En_Users getUserbyName(String userName)
        {
            e_u = d_u.getUserbyName(userName);
            return e_u;
        }
        [WebMethod]
        public String getTypeNamebyTypeID(int TypeID)
        {
            String s = d_u.getTypeName(TypeID);
            return s;
        }
        [WebMethod]
        public void UpDateProfileUser(String UserName, String UserFullName, int UserAge, String UserGender, String UserEmail)
        {
            d_u.UpDateProfileUser(UserName, UserFullName, UserAge, UserGender, UserEmail);
        }
        [WebMethod]
        public List<En_Facility> ShowFacility()
        {
            Lef = new List<En_Facility>();
            Lef =  d_u.ShowFacility();
            return Lef;
        }
        [WebMethod]
        public void InsertFacility(string FacilityName)
        {
            d_u.InSertFacility(FacilityName);
        }
        [WebMethod]
        public DataSet ShowAllUser()
        {
            DataSet ds = new DataSet();
            ds = d_u.ShowallUser();
            return ds;

        }
        [WebMethod]
        public void InsertUser(String UserID, String UserName, String UserPassword, String UserFullName, int UserAge, String UserGender, String UserEmail, int TypeID, int LoginStatus)
        {
            d_u.InsertUser(UserID,UserName,UserPassword,UserFullName,UserAge,UserGender,UserEmail,TypeID,LoginStatus);
        }
        [WebMethod]
        public int getTypeIDbyName(String TypeName)
        {
            int TypeID = d_u.getTypeIDbyTypeName(TypeName);
            return TypeID;
        }
        [WebMethod]
        public DataSet getAllUserTypeName()
        {
            DataSet ds = new DataSet();
            ds = d_u.getAllUserTypeName();
            return ds;
        }

        //Dung viet them
        [WebMethod]
        public void addRequest(string RequestTypeID, string UserID, string RequestTitle, string RequestContent, string RequestPriority, string RequestDate, string UserAssignee, string RequestStatus, string Remark)
        {

            d_r.addRequest(RequestTypeID, UserID, RequestTitle, RequestContent, RequestPriority, DateTime.Parse(RequestDate), UserAssignee, RequestStatus, Remark);

        }

        [WebMethod]
        public String getUserIDbyUserName(string UserName)
        {
            string s = d_r.getUserbyID(UserName);
            return s;
        }


        [WebMethod]
        public String getTypeNamebyTypeIDUser(int TypeID)
        {
            string s = d_r.getTypeNamebyTypeID(TypeID);
            return s;
        }

        [WebMethod]
        public void UpDateProfile(String UserName, String UserFullName, int UserAge, String UserGender, String UserEmail)
        {
            d_r.UpDateProfile(UserName, UserFullName, UserAge, UserGender, UserEmail);
        }

        [WebMethod]
        public void UpdatePassword(String UserName, String Password)
        {
            d_r.UpdatePassword(UserName, Password);
        }
        ///////
    }
}